import {useEffect,useState} from 'react'
import { Card} from 'antd';
import {getNewArticleList} from '@/api/index'

const gridStyle: React.CSSProperties = {
    width: '33.33%',
    textAlign: 'center',
  };
export default function NewArticle() {
    const [data,setdata]:any = useState([])
    useEffect(() =>{
        getNewArticleList().then(res=>{
            setdata(res.data[0]);
        })
    },[])
  return (
    <div  style={{ padding: '20px' }}>
        <Card title='最新文章' extra={<><a style={{ color: '#000' }} href="articleAll">全部文章</a></>}>
               {
                data&&data.map((item:any,index:number)=>{
                    return <Card.Grid style={gridStyle} key={index}>
                        <img style={{width: '100%',height: '130px'}} src={item.cover} alt="" />
                        <p>{item.title}</p>
                    </Card.Grid>
                })
               }
        </Card>
    </div>
  );
}
